Offset
The Offset command returns the offset of a string within a string. For example, the offset of"freedom now"
contained in"Yes, freedom now"
is 6, because the contained string begins with the sixth character of the container. The offset of"Yes"
in the string"Yes, freedom now"
is 1, because it begins with the first character of the container string. The Offset command is case-sensitive.Offset is one of several commands provided by the String Commands
scripting addition.SYNTAX
offset of stringToFind in stringToSearchPARAMETERS
- stringToFind
The string to find in stringToSearch.
Class: String
- stringToSearch
- A string containing stringToFind.
Class: StringRESULT
The result is an integer that indicates the offset, in number of characters, of
the first character of stringToFind from the beginning of stringToSearch. If stringToFind is not contained within stringToSearch, AppleScript returns the value 0.EXAMPLES
offset of "yours" in "yours, mine, and ours"--result: 1offset of "mine" in "yours, mine, and ours"--result: 8
offset of "this" in "yours, mine, and ours"--result: 0
offset of "Mine" in "yours, mine, and ours"--result: 0, due to case sensitivity
NOTES
The Offset command compares strings character by character, as the Equals operator does, except that the Offset command is always case-sensitive, always considers diacritical marks, and is not affected by Considering or Ignoring statements.ERRORS